package com.example.zs.appbarlayouttest.util;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

/**
 * Created by zs
 * Date：2017年 05月 04日
 * Time：13:57
 * —————————————————————————————————————
 * About:
 * —————————————————————————————————————
 */

public class RecyclerViewLocation {

    /**
     * 判断 RecyclerView 是否在顶部
     * @param recyclerView
     * @return
     */
    public static boolean isScrollTop(RecyclerView recyclerView){
        if (recyclerView != null){
            RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
            if (manager instanceof LinearLayoutManager){

                View view = recyclerView.getChildAt(0);
                if (view == null || manager.getDecoratedTop(view) == 0){
                    return true;
                }else{
                    return false;
                }
            }
        }
        return false;
    }
}
